package com.boot.security.server.service.impl.mffl.MfflOrder;

import com.boot.security.server.controller.mffl.MfflConsultation.Clinet_MfflConsultationController;
import com.boot.security.server.dao.mffl.MfflOrderDao;
import com.boot.security.server.model.mffl.MfflOrder;
import com.boot.security.server.model.mffl.Vo.OrderVo;
import com.boot.security.server.service.impl.mffl.MfflConsultation.MfflConsultationService;
import com.boot.security.server.service.impl.mffl.MfflContract.MfflContractService;
import com.boot.security.server.service.impl.mffl.MfflImageAndText.MfflImageAndTextService;
import com.boot.security.server.service.impl.mffl.MfflLawyerletter.MfflLawyerletterService;
import com.boot.security.server.utils.mffl.ReturnBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MfflOrderService {

    //律师函
    @Autowired
    private MfflLawyerletterService mfflLawyerletterService;
    //合同
    @Autowired
    private MfflContractService mfflContractService;
    //图文资讯
    @Autowired
    private MfflImageAndTextService mfflImageAndTextService;
    //打赏
    @Autowired
    private MfflConsultationService mfflConsultationService;
    //专业咨询
    @Autowired
    private Clinet_MfflConsultationController mfflConsultationController;

    @Autowired
    private MfflOrderDao mfflOrderDao;

    public ReturnBean updateOrderState() throws Exception {
        List<OrderVo> orderList = this.mfflOrderDao.getOrderListByPayState5();

        for (OrderVo o : orderList) {
            String payMerchantNumber = o.getPayMerchantNumber();
            if (o.getServierId() == 2 ){
                this.mfflConsultationController.orderquery(payMerchantNumber);
            }else if (o.getServierId() == 3 ){
                this.mfflLawyerletterService.orderquery(payMerchantNumber);
            }else if (o.getServierId() == 4 || o.getServierId() == 5){
                this.mfflContractService.orderquery(payMerchantNumber);
            }else if (o.getServierId() == 6 ){
                this.mfflImageAndTextService.orderquery(payMerchantNumber);
            }else if (o.getServierId() == 8 ){
                this.mfflConsultationService.orderquery(payMerchantNumber);
            }

        }

        return new ReturnBean();
    }

    public MfflOrder getBypaymerchantnumber(String paymerchantnumber){
        return mfflOrderDao.getBypaymerchantnumber(paymerchantnumber);
    }
}
